var order = ['red', 'yellow', 'blue', 'green', 'red']
Page({
  data: {
    toView: 'red',
    scrollTop: 100,
    ip: '',
    searchLogList:[],
    cardId:''
  },
  upper: function (e) {
    console.log(e)
  },
  lower: function (e) {
    console.log(e)
  },
  scroll: function (e) {
    console.log(e)
  },
  tap: function (e) {
    console.log("点击")
    for (var i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1]
        })
        break
      }
    }
  },
  tapMove: function (e) {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },
  dianji: function(e) {
    console.log(e);
    this.setData({
      ip: e.currentTarget.dataset.value
    });
  },
  onLoad: function(e) {//加载
    var ldata = this;
    wx.getStorage({
      key: 'logCache',
      success: function (res) {
        if (res.data != null && res.data.length > 0) {
          ldata.setData({
            searchLogList: res.data,
          });
        }
      },
    });
  },
  cardIdInput: function(e) {//输入卡号
    this.setData({
      cardId:e.detail.value
    });
  },
  search : function(e) {
    var cardId = this.data.cardId;
    if(cardId != null && cardId!='') {
      var logList = this.data.searchLogList;
      logList.push(cardId);
      wx.setStorage({
        key: "logCache",
        data: logList
      });
    }
  },
  selectItem: function(e) {
    this.setData({
      cardId: e.currentTarget.dataset.log
    })
  }
})